<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ujian_model extends CI_Model {

	public function get_list($bab_id = false){
		if(!$bab_id) return false;
		$this->db->where('bab_id',$bab_id);
		$this->db->where('publish','yes');
		$this->db->where('bab_id not in (select uj_jd_id from tbl_hasil_ujian where uj_user_id = '.$this->session->userdata('id_user').')');
		$this->db->order_by('rand()');
		return $this->db->get('tbl_soal');
	}

	public function get_bab($bab_id = false){
		if(!$bab_id) return false;
		$this->db->where('bab_id',$bab_id);
		return $this->db->get('ref_bab');
	}
	
	public function save($param = false){
		if(!$param) return false;
		return $this->db->insert('tbl_hasil_ujian',$param);
	}
}